package com.example.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Date;
@Component
@Aspect
public class MyAdvice {
    //定义切入点
    @Pointcut("execution(* com.example.service.impl.StudentServiceImpl.selectById(..))")
    public void pt(){}

    //切面
    //@AfterReturning("pt()")
    public void mthon(){
        System.out.println("操作时间"+System.currentTimeMillis()+"..."+new Date());
    }

    @Around("pt()")
    public Object mu(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("开始");
        Object proceed = proceedingJoinPoint.proceed();
        System.out.println("结束");
        return proceed;
    }
}
